package liangtWorkSpace.Observer.HeadFiestObsver.display;

import liangtWorkSpace.Observer.HeadFiestObsver.subject.Subject;

/**
 * @ClassName ForecastDisplay
 * @Description : 预告展示说明
 * @Author : LiangT
 * @Date : 2020/6/17 20:18
 */
public class ForecastDisplay implements Observer,DisplayElement {
    private float pressure;
    private float humidity;
    private float tempreature;
    private Subject weather;

    /**
     * 构造函数将自己注册到气象站中
     * @param weather
     */
    public ForecastDisplay(Subject weather) {
        this.weather = weather;
        weather.registerObserver(this);
    }

    @Override
    public void disPlay() {
        System.out.println("Forecast: "+humidity+" humidity "
        +" tempreature "+tempreature+" %");
    }

    @Override
    public void update(float temp, float hunidity, float pressure) {
        this.tempreature = temp;
        this.humidity = hunidity;
        disPlay();
    }
}
